audioRecord.startRecording();

while (!isDestroy) {
    byte[] buffer = new byte[bufferSize];
    long readCount = audioRecord.read(buffer, 0, bufferSize);
    long v = 0;
    for (int i = 0; i < buffer.length; i++) {
        v += buffer[i] * buffer[i];
    }
    double mean = v / (double) readCount;
    double volume = 10 * Math.log10(mean); // 以 10 为底的对数

    if (null != handler) {
        Message message = handler.obtainMessage();
        message.obj = volume;
        handler.sendMessage(message);
    }
}//--------- while

audioRecord.stop();